# Maintainer: Andrew Sun <adsun701@gmail.com>

_realname=gavl
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.4.0
pkgrel=1
pkgdesc="A low level library, upon which multimedia APIs can be built. (mingw-w64)"
arch=('any')
url="https://gmerlin.sourceforge.io/"
license=("GPL")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc" "${MINGW_PACKAGE_PREFIX}-pkg-config")
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs" "${MINGW_PACKAGE_PREFIX}-libpng")
options=('!libtool')
source=("https://downloads.sourceforge.net/sourceforge/gmerlin/${_realname}-${pkgver}.tar.gz"
        "0001-gavl-1.4.0-fix-64-bit-compilation.patch"
        "0002-gavl-1.4.0-fix-shared-dll-installation.patch")
sha256sums=('51aaac41391a915bd9bad07710957424b046410a276e7deaff24a870929d33ce'
            '5d4b74dd6caa0d8c87945820785bc63918d2b74edaba07a4b1c566c9e544e976'
            '091f2990f75ddb212752b8ed5e0ab509dd6292e2593411ca387a44fc7ec9ece3')
prepare(){
  cd "${srcdir}/${_realname}-${pkgver}"
  patch -Np1 -i "${srcdir}/0001-gavl-1.4.0-fix-64-bit-compilation.patch"
  patch -Np1 -i "${srcdir}/0002-gavl-1.4.0-fix-shared-dll-installation.patch"
  autoreconf -fiv
}

build() {
  [[ -d "build-${MINGW_CHOST}" ]] && rm -rf "build-${MINGW_CHOST}"
  mkdir -p "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"

  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --with-cpuflags=none \
    --enable-static \
    --enable-shared \
    --without-doxygen

  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR=${pkgdir} install
}
